import { createRouter, createWebHistory } from 'vue-router'
import type { RouteRecordRaw } from 'vue-router'
import AdminLayout from '../layout/AdminLayout.vue'

export const adminRoutes: RouteRecordRaw = [
  // 能力接入域
  {
    path: '/',
    redirect: '/access/index',
    component: AdminLayout,
    meta: { index: 0 },
    children: [
      {
        path: '/access',
        hidden: true,
        redirect: '/access/index'
      },
      {
        path: '/access/index',
        name: 'index',
        meta: { title: '概览', icon: 'House', affix: true },
        component: () => import('../views/access/Home.vue')
      },
      {
        path: '/access/abilityList',
        name: 'abilityList',
        meta: { title: '能力清单', icon: 'Memo' },
        component: () => import('../views/access/abilityList/index.vue')
      },
      {
        path: '/access/review',
        name: 'review',
        meta: { title: '能力评审', icon: 'Coffee' },
        component: () => import('../views/access/review/index.vue')
      },
      {
        path: '/access/test',
        name: 'access_test',
        meta: { title: '能力测试', icon: 'Paperclip' },
        component: () => import('../views/access/test/index.vue')
      },

      // {
      //   path: '/access/category',
      //   name: 'access-category',
      //   meta: { title: '类目管理', icon: 'Document' },
      //   component: () => import('../views/access/category-mgt/category.vue')
      // },
      // {
      //   path: '/access/provider',
      //   name: 'access-provider',
      //   meta: { title: '提供方管理', icon: 'SetUp' },
      //   component: () => import('../views/access/provider-mgt/provider.vue')
      // },

      {
        path: '/access/on',
        name: 'access_on',
        meta: { title: '上架管理', icon: 'Upload' },
        component: () => import('../views/access/on/index.vue')
      },

      {
        path: '/access/pull',
        name: 'access-pull',
        meta: { title: '拉取管理', icon: 'Download' },
        component: () => import('../views/access/pull-mgt/pull.vue')
      },
      {
        path: '/access/off',
        name: 'access_off',
        meta: { title: '下架管理', icon: 'Download' },
        component: () => import('../views/access/off/index.vue')
      },
      {
        path: '/access/tag',
        name: 'access-tag',
        meta: { title: '标签管理', icon: 'Discount' },
        component: () => import('../views/access/tag-mgt/tag.vue')
      },
      {
        path: '/access/code',
        name: 'access-code',
        meta: { title: '码号管理', icon: 'CollectionTag' },
        component: () => import('../views/access/code-mgt/code.vue')
      },
      {
        path: '/access/api',
        meta: { title: 'api管理', icon: 'Menu' },
        component: () => import('./routerView.vue'),
        children: [
          {
            path: '/access/api/template',
            name: 'api_template',
            meta: { title: 'api模板', icon: 'Money', iframe: 'http://10.12.6.88/open/admin/gateway/ListApiTemplateManage' },
            component: () => import('@/layout/admin/iframe/index.vue')
          },
          {
            path: '/access/api/bussiness',
            name: 'api_bussiness',
            meta: {
              title: '业务域管理',
              icon: 'Paperclip',
              iframe: 'http://10.12.6.88/open/admin/gateway/apiportal/standard/ListBuinessDomain'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          }
        ]
      },
      // {
      //   path: '/access/router',
      //   meta: { title: '服务路由', icon: 'Share' },
      //   component: () => import('./routerView.vue'),
      //   children: [
      //     {
      //       path: '/access/router/all',
      //       name: 'router_all',
      //       meta: {
      //         title: '所有路由配置',
      //         icon: 'Share',
      //         iframe: 'http://10.12.6.88/open/admin/gateway/routerConfig/router?gatewayAppId=all'
      //       },
      //       component: () => import('@/layout/admin/iframe/index.vue')
      //     }
      //   ]
      // },
      {
        path: '/access/net',
        meta: { title: '网关配置', icon: 'Operation' },
        component: () => import('./routerView.vue'),
        children: [
          {
            path: '/access/net/back',
            name: 'net_back',
            meta: {
              title: '后端服务管理',
              icon: 'Box',
              iframe: 'http://10.12.6.88/open/admin/gateway/gatewayConfig/ListServices'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          },
          {
            path: '/access/net/one',
            name: 'net_one',
            meta: {
              title: '统一认证管理',
              icon: 'Select',
              iframe: 'http://10.12.6.88/open/admin/gateway/gatewayConfig/ListAuthentication'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          },
          // {
          //   path: '/access/net/fa',
          //   name: 'net_fa',
          //   meta: {
          //     title: '灰度发布配置',
          //     icon: 'Refresh',
          //     iframe: 'http://10.12.6.88/open/admin/gateway/gatewayConfig/GrayRuleRelease'
          //   },
          //   component: () => import('@/layout/admin/iframe/index.vue')
          // },
          {
            path: '/access/net/kong',
            name: 'net_kong',
            meta: {
              title: '网关控制策略',
              icon: 'More',
              iframe: 'http://10.12.6.88/open/admin/gateway/gatewayConfig/APIControllerStrategy'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          },
          // {
          //   path: '/access/net/fu',
          //   name: 'net_fu',
          //   meta: {
          //     title: '负载均衡策略',
          //     icon: 'ChatLineSquare',
          //     iframe: 'http://10.12.6.88/open/admin/gateway/gatewayConfig/LoadBalanceStrategy'
          //   },
          //   component: () => import('@/layout/admin/iframe/index.vue')
          // },
          // {
          //   path: '/access/net/type',
          //   name: 'net_type',
          //   meta: {
          //     title: '路由分类管理',
          //     icon: 'Connection',
          //     iframe: 'http://10.12.6.88/open/admin/gateway/gatewayConfig/GatewayAppList'
          //   },
          //   component: () => import('@/layout/admin/iframe/index.vue')
          // },
          {
            path: '/access/net/quan',
            name: 'net_quan',
            meta: {
              title: '全局变量配置',
              icon: 'Tools',
              iframe: 'http://10.12.6.88/open/admin/gateway/gatewayConfig/VariantConfig'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          }
        ]
      },
      {
        path: '/access/data',
        meta: { title: '数据转换', icon: 'Tools' },
        component: () => import('./routerView.vue'),
        children: [
          {
            path: '/access/data/request',
            name: 'data_request',
            meta: {
              title: '请求数据转换',
              icon: 'Switch',
              iframe: 'http://10.12.6.88/open/admin/gateway/dataConfig/reqDataFilters'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          },
          {
            path: '/access/data/mo',
            name: 'data_mo',
            meta: {
              title: '模拟数据管理',
              icon: 'ZoomOut',
              iframe: 'http://10.12.6.88/open/admin/gateway/dataConfig/MockData'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          },
          {
            path: '/access/data/xml',
            name: 'data_xml',
            meta: {
              title: 'xml模板管理',
              icon: 'Cellphone',
              iframe: 'http://10.12.6.88/open/admin/gateway/dataConfig/MockXMLData'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          },
          {
            path: '/access/data/rule',
            name: 'data_rule',
            meta: {
              title: '数据缓存规则',
              icon: 'Wallet',
              iframe: 'http://10.12.6.88/open/admin/gateway/dataConfig/dataCacheConfig'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          }
        ]
      },
      {
        path: '/access/safe',
        meta: { title: '安全设置', icon: 'StarFilled' },
        component: () => import('./routerView.vue'),
        children: [
          {
            path: '/access/safe/ip',
            name: 'safe_id',
            meta: {
              title: 'ip黑白名单配置',
              icon: 'InfoFilled',
              iframe: 'http://10.12.6.88/open/admin/gateway/securityConfig/ipConfig'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          },
          {
            path: '/access/safe/tong',
            name: 'safe_tong',
            meta: {
              title: '敏感字符配置',
              icon: 'WarningFilled',
              iframe: 'http://10.12.6.88/open/admin/gateway/securityConfig/wordConfig'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          },
          {
            path: '/access/safe/data',
            name: 'safe_data',
            meta: {
              title: '数据加密配置',
              icon: 'Aim',
              iframe: 'http://10.12.6.88/open/admin/gateway/securityConfig/encryConfig'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          }
        ]
      }
    ]
  },
  // 能力开发域
  // {
  //   path: '/dev',
  //   component: AdminLayout,
  //   redirect: '/dev/service/all',
  //   meta: { index: 1 },
  //   children: [
  //     {
  //       path: '/dev/service',
  //       meta: { title: '服务编排', icon: 'Edit' },
  //       redirect: '/dev/service/all',
  //       component: () => import('./routerView.vue'),
  //       children: [
  //         {
  //           path: '/dev/service/all',
  //           name: 'service_all',
  //           meta: {
  //             title: '所有应用',
  //             icon: 'Menu',
  //             iframe: 'http://10.12.6.88/esb/admin/esb/APPDesigner/ListApplications?categoryId=*'
  //           },
  //           component: () => import('@/layout/admin/iframe/index.vue')
  //         },
  //         {
  //           path: '/dev/service/my',
  //           name: 'service_my',
  //           meta: {
  //             title: '我的应用',
  //             icon: 'Files',
  //             iframe: 'http://10.12.6.88/esb/admin/esb/APPDesigner/ListApplications?categoryId=myapps'
  //           },
  //           component: () => import('@/layout/admin/iframe/index.vue')
  //         },
  //         {
  //           path: '/dev/service/html',
  //           name: 'service_html',
  //           meta: {
  //             title: 'HTML视图模板',
  //             icon: 'ScaleToOriginal',
  //             iframe: 'http://10.12.6.88/esb/admin/esb/HTMLTemplate'
  //           },
  //           component: () => import('@/layout/admin/iframe/index.vue')
  //         },
  //         {
  //           path: '/dev/service/public',
  //           name: 'service_public',
  //           meta: {
  //             title: '公共组件库',
  //             icon: 'Collection',
  //             iframe: 'http://10.12.6.88/esb/admin/esb/nodeTemplateCategory'
  //           },
  //           component: () => import('@/layout/admin/iframe/index.vue')
  //         },
  //         {
  //           path: '/dev/service/log',
  //           name: 'service_log',
  //           meta: {
  //             title: '被编排的API',
  //             icon: 'SetUp',
  //             iframe: 'http://10.12.6.88/esb/admin/esb/cpumonitor/joinApis'
  //           },
  //           component: () => import('@/layout/admin/iframe/index.vue')
  //         }
  //       ]
  //     },
  //     {
  //       path: '/dev/page',
  //       meta: { title: '页面编排', icon: 'EditPen' },
  //       component: () => import('./routerView.vue'),
  //       children: [
  //         {
  //           path: '/dev/page/my',
  //           name: 'page_my',
  //           meta: {
  //             title: '我的应用',
  //             icon: 'Files',
  //             iframe: 'http://10.12.6.88/ld/admin/application/APPDesigner/ListApplications?categoryId=myapps'
  //           },
  //           component: () => import('@/layout/admin/iframe/index.vue')
  //         },
  //         {
  //           path: '/dev/page/dev',
  //           name: 'page_dev',
  //           meta: {
  //             title: '开发测试',
  //             icon: 'Pointer',
  //             iframe: 'http://10.12.6.88/ld/admin/application/APPDesigner/ListApplications?categoryId=dev'
  //           },
  //           component: () => import('@/layout/admin/iframe/index.vue')
  //         },
  //         {
  //           path: '/dev/page/tag',
  //           name: 'page_tag',
  //           meta: {
  //             title: '版本管理',
  //             icon: 'FullScreen',
  //             iframe: 'http://10.12.6.88/ld/admin/application/APPDesigner/AppVersionManager'
  //           },
  //           component: () => import('@/layout/admin/iframe/index.vue')
  //         }
  //       ]
  //     }
  //   ]
  // },
  {
    path: '/dev',
    component: AdminLayout,
    // redirect: '/dev/service/all',
    meta: { index: 1 },
    children: [
      {
        path: '/dev/service',
        meta: { title: '服务编排', icon: 'Star' },
        redirect: '/dev/service/my',
        component: () => import('./routerView.vue'),
        children: [
          // {
          //   path: '/dev/service/all',
          //   name: 'service_all',
          //   meta: {
          //     title: '所有应用',
          //     icon: 'Menu',
          //     iframe: 'http://10.12.6.88/esb/admin/esb/APPDesigner/ListApplications?categoryId=*'
          //   },
          //   component: () => import('@/layout/admin/iframe/index.vue')
          // },
          {
            path: '/dev/service/my',
            name: 'servicemy',
            meta: {
              title: '我的应用',
              icon: 'Aim',
              iframe: 'http://10.12.6.88/open/admin/esb/APPDesigner/ListApplications'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          },
          {
            path: '/dev/service/html',
            name: 'service_html',
            meta: {
              title: 'HTML视图模板',
              icon: 'Operation',
              iframe: 'http://10.12.6.88/open/admin/esb/HTMLTemplate'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          },
          {
            path: '/dev/service/public',
            name: 'service_public',
            meta: {
              title: '公共组件库',
              icon: 'MessageBox',
              iframe: 'http://10.12.6.88/open/admin/esb/nodeTemplateCategory'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          },
          {
            path: '/dev/service/log',
            name: 'service_log',
            meta: {
              title: '被编排的API',
              icon: 'Notification',
              iframe: 'http://10.12.6.88/open/admin/esb/cpumonitor/joinApis'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          }
        ]
      },
      {
        path: '/dev/page',
        meta: { title: '页面编排', icon: 'FullScreen' },
        component: () => import('./routerView.vue'),
        children: [
          {
            path: '/dev/page/my',
            name: 'page_my',
            meta: {
              title: '我的应用',
              icon: 'Filter',
              iframe: 'http://10.12.6.88/open/admin/application/APPDesigner/ListApplications?categoryId=myapps'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          },
          {
            path: '/dev/page/sys',
            name: 'page_sys',
            meta: {
              title: '应用列表',
              icon: 'Finished',
              iframe: 'http://10.12.6.88/open/admin/application/system/manage'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          },
          {
            path: '/dev/page/dev',
            name: 'page_dev',
            meta: {
              title: '租户管理',
              icon: 'User',
              iframe: 'http://10.12.6.88/open/admin/application/system/tenant'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          },
          {
            path: '/dev/page/tag',
            name: 'page_tag',
            meta: {
              title: '版本管理',
              icon: 'Warning',
              iframe: 'http://10.12.6.88/open/admin/application/APPDesigner/AppVersionManager'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          }
        ]
      }
    ]
  },
  // 能力管控域
  {
    path: '/monitor',
    component: AdminLayout,
    meta: { index: 2 },
    redirect: '/monitor/service/all',
    children: [
      {
        path: '/monitor/service',
        meta: { title: 'API监控中心', icon: 'VideoCamera' },
        redirect: '/monitor/service/all',
        component: () => import('./routerView.vue'),
        children: [
          {
            path: '/monitor/service/all',
            name: 'service_all',
            meta: {
              title: '实时请求监控',
              icon: 'VideoCameraFilled',
              iframe: 'http://10.12.6.88/open/admin/monitor/apiRunTime/ListRealTimeRequestInfo'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          },
          {
            path: '/monitor/service/my',
            name: 'service_my',
            meta: {
              title: '实时运行监控',
              icon: 'Camera',
              iframe: 'http://10.12.6.88/open/admin/monitor/apiRunTime/ListServices'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          },
          {
            path: '/monitor/service/errhtml',
            name: 'service_errhtml',
            meta: {
              title: '执行异常监控',
              icon: 'Iphone',
              iframe: 'http://10.12.6.88/open/admin/monitor/apiRunTime/ListException'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          }
        ]
      },
      {
        path: '/monitor/containerindex',
        name: 'monitor/containerIndex',
        meta: { title: '容器监控', icon: 'CameraFilled', affix: true },
        component: () => import('./routerView.vue'),
        children: [
          {
            path: '/monitor/containers/all',
            name: 'servicecontainersall',
            meta: {
              title: '对象容器监控',
              icon: 'Monitor',
              iframe: 'http://10.12.6.88/open/admin/monitor/platform/ListBeans'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          },
          {
            path: '/monitor/springbean/all',
            name: '/monitorspringbeanall',
            meta: {
              title: 'SpringBean监控',
              icon: 'DataLine',
              iframe: 'http://10.12.6.88/open/admin/monitor/platform/ListSpringBean'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          },
          {
            path: '/monitor/jar/all',
            name: 'monitor/jarall',
            meta: {
              title: '加载的Jar包列表',
              icon: 'Memo',
              iframe: 'http://10.12.6.88/open/admin/monitor/platform/ListLoadJarFiles'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          }
        ]
      },
      {
        path: '/monitor/applianceindex',
        name: 'monitor/applianceIndex',
        meta: { title: '应用服务器监控', icon: 'Film', affix: true },
        component: () => import('./routerView.vue'),
        children: [
          {
            path: '/monitor/cluster/all',
            name: 'serviceCluster',
            meta: {
              title: '集群服务器监控',
              icon: 'Coin',
              iframe: 'http://10.12.6.88/open/admin/monitor/serverMonitor/ListClusterServer'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          },
          {
            path: '/monitor/ram/all',
            name: 'serviceallRam',
            meta: {
              title: '内存及线程监控',
              icon: 'Cpu',
              iframe: 'http://10.12.6.88/open/admin/monitor/serverMonitor/JvmMonitor'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          }
        ]
      }
    ]
  },
  // 能力运营域
  {
    path: '/operation',
    component: AdminLayout,
    meta: { index: 3 },
    children: [
      {
        path: '/operation/service',
        meta: { title: '调用统计分析', icon: 'Histogram' },
        redirect: '/operation/call/all',
        component: () => import('./routerView.vue'),
        children: [
          {
            path: '/operation/call/all',
            name: 'service_day',
            meta: {
              title: '每日调用次数',
              icon: 'Finished',
              iframe: 'http://10.12.6.88/open/admin/monitor/apiReport/ApiCallsByWeekChart'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          },
          {
            path: '/operation/service/my',
            name: 'operation/number',
            meta: {
              title: '调用次数及性能',
              icon: 'Stopwatch',
              iframe: 'http://10.12.6.88/open/admin/monitor/apiReport/ListReportApiAccessLog'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          },
          {
            path: '/operation/distribution/html',
            name: 'distribution_html',
            meta: {
              title: '平均性能分布图',
              icon: 'Postcard',
              iframe: 'http://10.12.6.88/open/admin/monitor/apiReport/ApiPerformanceChart'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          },
          {
            path: '/operation/status/html',
            name: 'service_statushtml',
            meta: {
              title: '状态码分布统计',
              icon: 'Document',
              iframe: 'http://10.12.6.88/open/admin/monitor/apiReport/ErrorCodeCharts'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          },
          {
            path: '/operation/serviceNumber/html',
            name: 'service_serviceNumberhtml',
            meta: {
              title: '服务器调用次数',
              icon: 'Mouse',
              iframe: 'http://10.12.6.88/open/admin/monitor/apiReport/ServerCallStatisChart'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          },
          {
            path: '/operation/serviceErrapi/html',
            name: 'service_serviceErrapihtml',
            meta: {
              title: '异常API列表',
              icon: 'Warning',
              iframe: 'http://10.12.6.88/open/admin/monitor/apiReport/ListInvalidApis'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          }
        ]
      },
      {
        path: '/monitor/APMindex',
        name: 'monitorAPMIndex',
        meta: { title: 'APM链路分析', icon: 'Rank', affix: true },
        // component: () => import('../views/monitor/Home.vue'),
        component: () => import('./routerView.vue'),
        children: [
          {
            path: '/operation/serviceTrack/all',
            name: 'service_serviceTrackall',
            meta: {
              title: '跟踪服务实例',
              icon: 'Connection',
              iframe: 'http://10.12.6.88/open/admin/monitor/apm/apmbyuser'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          },
          {
            path: '/operation/serviceUserApi/all',
            name: 'serviceUserApi',
            meta: {
              title: '按用户跟踪API',
              icon: 'ZoomIn',
              iframe: 'http://10.12.6.88/open/admin/monitor/apm/ApmUserAndAPI'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          },
          {
            path: '/operation/rely/all',
            name: 'service_relyall',
            meta: {
              title: 'API依赖关系',
              icon: 'Share',
              iframe: 'http://10.12.6.88/open/admin/monitor/apm/ApmBySystemName'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          }
        ]
      },
      {
        path: '/operation/callindex',
        name: 'operationCallIndex',
        meta: { title: '调用分析', icon: 'DataAnalysis', affix: true },
        // component: () => import('../views/monitor/Home.vue'),
        component: () => import('./routerView.vue'),
        children: [
          {
            path: '/operation/serviveNumber/all',
            name: 'operationserviveNumberall',
            meta: {
              title: '应用调用次数Top',
              icon: 'Medal',
              iframe: 'http://10.12.6.88/open/admin/monitor/apiReport/AppCallStatis'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          },
          {
            path: '/operation/userNumber/all',
            name: 'operationuserNumberall',
            meta: {
              title: '用户调用次数Top',
              icon: 'Medal',
              iframe: 'http://10.12.6.88/open/admin/monitor/apiReport/UserCallTopStatis'
            },
            component: () => import('@/layout/admin/iframe/index.vue')
          }
        ]
      }
    ]
  }
]

const routes: RouteRecordRaw[] = adminRoutes

const router = createRouter({
  history: createWebHistory(`${import.meta.env.VITE_BASE}/admin`),
  routes: [...routes]
})

router.beforeEach((to, from, next) => {
  document.title = to.meta.title || import.meta.env.VITE_SYS_NAME
  next()
})
export default router
